package com.preskool.controller;

import com.preskool.dto.ActionResult;
import com.preskool.po.Events;
import com.preskool.service.DashboardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * TODO
 *
 * @author ZhaoBo
 * @description: 仪表板的查询信息
 * @date 2021/1/7  16:50
 */
@RestController
@Api(value = "仪表板的接口文档")
public class DashboardController {
    @Autowired
    private DashboardService dashboardService;

    /**
     * 查询学生总数量
     * @return
     */
    @ApiOperation(value = "Dashboard:studentCount",httpMethod = "GET",notes = "查询学生总数量")
    @RequestMapping(value = "/studentCount",method = RequestMethod.GET)
    public ActionResult findStudentNum(){
        int count = dashboardService.findStudentCount();
        return new ActionResult(200,"",count);
    }

    /**
     * 查询老师总数
     * @return
     */
    @ApiOperation(value = "Dashboard:teacherCount",httpMethod = "GET",notes = "查询老师总数")
    @RequestMapping(value = "/teacherCount",method = RequestMethod.GET)
    public ActionResult findSTeacherCount(){
        int count = dashboardService.findTeacherCount();
        return new ActionResult(200,"",count);
    }

    /**
     * 查询部门总数量
     * @return
     */
    @ApiOperation(value = "Dashboard:deptCount",httpMethod = "GET",notes = "查询部门总数量")
    @RequestMapping(value = "/deptCount",method = RequestMethod.GET)
    public ActionResult findDeptNum(){
        int count = dashboardService.findDepartmentCount();
        return new ActionResult(200,"",count);
    }

    /**
     * 查询平均工资
     * @return
     */
    @ApiOperation(value = "Dashboard:salaryAvg",httpMethod = "GET",notes = "查询平均工资")
    @RequestMapping(value = "/salaryAvg",method = RequestMethod.GET)
    public ActionResult findSalaryAvg(){
        double salaryAvg = dashboardService.findSalaryAvg();
        return new ActionResult(200,"",salaryAvg);
    }

    /**
     * 学校收入
     * @return
     */
    @ApiOperation(value = "Dashboard:expensesNum",httpMethod = "GET",notes = "学校收入")
    @RequestMapping(value = "/expensesNum",method = RequestMethod.GET)
    public ActionResult findExpenses(){
        Double[] amounts = dashboardService.findPurchaseByDate("1","1");
        return new ActionResult(200,"",amounts);
    }

    /**
     * 学校支出
     * @return
     */
    @ApiOperation(value = "Dashboard:feesNum",httpMethod = "GET",notes = "学校支出")
    @RequestMapping(value = "/feesNum",method = RequestMethod.GET)
    public ActionResult findFees(){
        Double[] amounts = dashboardService.findPurchaseByFees("1","1");
        return new ActionResult(200,"",amounts);
    }

    /**
     * 全部男学生
     * @return
     */
    @ApiOperation(value = "Dashboard:findStudentNan",httpMethod = "GET",notes = "全部男学生")
    @RequestMapping(value = "/findStudentNan",method = RequestMethod.GET)
    public ActionResult findStudentNan(){
        int[] studentByGenderNan = dashboardService.findStudentByGenderNan();
        return new ActionResult(200,"",studentByGenderNan);
    }

    /**
     * 全部女学生
     * @return
     */
    @ApiOperation(value = "Dashboard:findStudentNv",httpMethod = "GET",notes = "全部女学生")
    @RequestMapping(value = "/findStudentNv",method = RequestMethod.GET)
    public ActionResult findStudentNv(){
        int[] studentByGenderNv = dashboardService.findStudentByGenderNv();
        return new ActionResult(200,"",studentByGenderNv);
    }

    /**
     * 查询全部大事记
     * @return
     */
    @ApiOperation(value = "Dashboard:findEventsAll",httpMethod = "GET",notes = "查询全部大事记")
    @RequestMapping(value = "/findEventsAll",method = RequestMethod.GET)
    public ActionResult findEventsAll(){
        List<Events> events = dashboardService.findEvents();
        return new ActionResult(200,"",events);
    }
}
